What is the logic to write C program in ascending or descending order